﻿#ifndef ANDYRP_LIGHT_INCLUDED
#define ANDYRP_LIGHT_INCLUDED

#define MAX_VISUAL_LIGHT_COUNT 4

CBUFFER_START(_CustomLight)
	int _LightCount;
	float4 _LightDirOrPos[MAX_VISUAL_LIGHT_COUNT];
	float4 _LightColors[MAX_VISUAL_LIGHT_COUNT];
	float4 _LightAtten[MAX_VISUAL_LIGHT_COUNT];
    float4 _SpotLightDir[MAX_VISUAL_LIGHT_COUNT];
CBUFFER_END

/*
CBUFFER_START(_ShadowBuffer)

float4x4 _WorldToShadowMatrix;
CBUFFER_END

TEXTURE2D_SHADOW(_ShadowMap);
SAMPLER_CMP(sampler_ShadowMap);

float ShadowAttenuation(float3 worldPos)
{
    float4 shadowPos = mul(_WorldToShadowMatrix, float4(worldPos, 1.0));
    shadowPos.xyz /= shadowPos.w;
    return SAMPLE_TEXTURE2D_SHADOW(_ShadowMap, sampler_ShadowMap, shadowPos.xyz);
}
*/

int GetLightCount()
{
	return _LightCount;
}

struct Light
{
	float3 color;
	float4 directionOrpos;
	float4 atten;
	float3 spotLightDir;
};


Light GetLight(int index)
{
	Light light;
	light.color = _LightColors[index].rgb;
	light.directionOrpos = _LightDirOrPos[index];
	light.atten = _LightAtten[index];
    light.spotLightDir = _SpotLightDir[index].xyz;
	return light;
}



#endif